package com.medicine.hbp.adapter;

import org.kymjs.kjframe.KJBitmap;

import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.medicine.hbp.base.MyBaseAdapter;
import com.medicine.hbp.mob.findLaberAllByParentIdlistVo;
import com.medicine.hbp.ui.LabelDetailActivity;
import com.medicine.hbp.R;

public class FragmentGrid04 extends MyBaseAdapter {
	KJBitmap kjBitmap=new KJBitmap();
	public FragmentGrid04(Activity activity) {
		this.activity=activity;
	}

	@Override
	public View getView(int position, View arg1, ViewGroup arg2) {
		View view = null;
		ViewHolder holder;
		if(view==null){
			holder=new ViewHolder();
			view=LayoutInflater.from(activity).inflate(R.layout.item_grid_img, null);
			holder.text=(TextView) view.findViewById(R.id.text);
			holder.view=(ImageView) view.findViewById(R.id.img_view);
			view.setTag(holder);
		}else{
			holder=(ViewHolder) view.getTag();
		}
		final findLaberAllByParentIdlistVo vo=(findLaberAllByParentIdlistVo) getItem(position);
		if(vo!=null){
			holder.text.setText(vo.laberNote);
			kjBitmap.display(holder.view, vo.laberImg);
			view.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent=new Intent(activity,LabelDetailActivity.class);
					intent.putExtra("vo", vo);
					activity.startActivity(intent);
				}
			});
		}
		return view;
	}
	class ViewHolder{
		TextView text;
		ImageView view;
	}
}
